import json

from framework.core.crawler_result import Result
# from framework.core.crawler_signal import Signal
from framework.core.crawler_task import Task


class PtEncoder(json.JSONEncoder):
    def default(self, obj):
        # if isinstance(obj, Result) or isinstance(obj, Task) or isinstance(obj, Signal):
        if isinstance(obj, Result) or isinstance(obj, Task):
            return obj.__dict__
        else:
            return json.JSONEncoder.default(self, obj)
